package miiteen.twoexploit.service;


import miiteen.data.dao.BaseDao;
import miiteen.data.service.impl.BaseServiceImpl;
import miiteen.hr.pubconfig.CurrentHrInfo;
import miiteen.hr.user.beans.UserUserInfo;
import miiteen.sys.login.bean.UserShiro;
import miiteen.sys.login.utils.LoginUtil;
import miiteen.twoexploit.beans.Answering;
import miiteen.twoexploit.dao.AnsweringDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;

/**
 * Name: lzhg_two_instructor
 * Des: -Service
 * Author: qyp
 * Date: 2021-10-20
 * 留言
 */
@Service("AnsweringService")
public class AnsweringService extends BaseServiceImpl<Answering>{

	@Autowired
	private AnsweringDao answeringDao;


	@Override
	protected BaseDao<Answering> getDao() {
		return answeringDao;
	}


	@Override
	@Transactional
	public long save(Answering answering){
		UserShiro.ShiroUser shiroUser= LoginUtil.getCurUser();
		UserUserInfo user= CurrentHrInfo.getUserInfo(shiroUser);
		long result=-1;

		answering.setMessageDate(new Date());
		//大于零就是修改
		if(answering.getId()>0){
			answering.setUpdateDate(new Date());
			answering.setUpdateId(user.getId());
		}else{
			answering.setCreateDate(new Date());
			answering.setCreateId(user.getId());
		}
		result= answeringDao.save(answering);

		return result;
	}
}